//
//  LineView.m
//  FinancialProduct
//
//  Created by Stella on 2017/9/9.
//  Copyright © 2017年 maq. All rights reserved.
//
#import "UIView+Extend.h"
#import "UIColor+NN.h"
#import "LineView.h"
#import "CKPuslichTool.h"

@implementation LineView


- (instancetype)initWithFrame:(CGRect)frame lineCount:(int)count
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.pieCenter = CGPointMake(self.width/2, self.height/2);
        self.lineCount=count;
    }
    NSLog(@"self.width:%f, self.height:%f",self.width,self.height);
    return self;
}

- (void)drawRect:(CGRect)rect {
    
    CAShapeLayer *lineLayer = [CAShapeLayer layer];
    UIColor *lineColor=[UIColor colorWithHexString:@"#BB3535"];
    lineLayer.strokeColor = [lineColor CGColor];
    lineLayer.fillColor = [UIColor clearColor].CGColor;
    [self.layer addSublayer:lineLayer];

    UIBezierPath *linePath = [UIBezierPath bezierPath];
    
    if (self.lineCount==4) {
        //1
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2+60, 0)];
        [linePath addLineToPoint:CGPointMake(self.width/2+110, 0)];
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2-60, 0)];
        [linePath addLineToPoint:CGPointMake(self.width/2-120, 0)];
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2-60, 120)];
        [linePath addLineToPoint:CGPointMake(self.width/2-120, 120)];
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2+60, 120)];
        [linePath addLineToPoint:CGPointMake(self.width/2+110, 120)];
    }else if (self.lineCount==3){
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2, self.height/2-80)];
        [linePath addLineToPoint:CGPointMake(self.width/2+20, self.height/2-80)];
        [linePath moveToPoint:CGPointMake(self.width/2, self.height/2-80)];
        [linePath addLineToPoint:CGPointMake(self.width/2-20, self.height/2-80)];
      
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2-60, 120)];
        [linePath addLineToPoint:CGPointMake(self.width/2-110, 120)];
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2+60, 120)];
        [linePath addLineToPoint:CGPointMake(self.width/2+110, 120)];
    }else{
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2+60, 0)];
        [linePath addLineToPoint:CGPointMake(self.width/2+110, 0)];
        [linePath moveToPoint:self.center];
        [linePath addLineToPoint:CGPointMake(self.width/2-60, 120)];
        [linePath addLineToPoint:CGPointMake(self.width/2-110, 120)];
    }
    
   
    lineLayer.path = linePath.CGPath;
    
}


@end
